/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package modelo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Francisco
 */
@Entity
@Table(name = "consumible")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Consumible.findAll", query = "SELECT c FROM Consumible c"),
    @NamedQuery(name = "Consumible.findByIdConsumible", query = "SELECT c FROM Consumible c WHERE c.idConsumible = :idConsumible"),
    @NamedQuery(name = "Consumible.findByCosto", query = "SELECT c FROM Consumible c WHERE c.costo = :costo"),
    @NamedQuery(name = "Consumible.findByNombre", query = "SELECT c FROM Consumible c WHERE c.nombre = :nombre"),
    @NamedQuery(name = "Consumible.findByEstatus", query = "SELECT c FROM Consumible c WHERE c.estatus = :estatus")})
public class Consumible implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "id_consumible")
    private Integer idConsumible;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "costo")
    private BigDecimal costo;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 50)
    @Column(name = "nombre")
    private String nombre;
    @Size(max = 200)
    @Column(name = "descripcion")
    private String descripcion;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 1)
    @Column(name = "estatus")
    private String estatus;
    @JoinTable(name = "consumible_categoria", joinColumns = {
        @JoinColumn(name = "id_consumible", referencedColumnName = "id_consumible")}, inverseJoinColumns = {
        @JoinColumn(name = "id_categoria", referencedColumnName = "id_categoria")})
    @ManyToMany
    private List<Categoria> categoriaList;
    @JoinColumn(name = "id_persona_proveedor", referencedColumnName = "id_persona")
    @ManyToOne
    private Persona idPersonaProveedor;
    @JoinColumn(name = "id_usuario", referencedColumnName = "id_usuario")
    @ManyToOne(optional = false)
    private Usuario idUsuario;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idConsumible")
    private List<OperarConsumoConsumible> operarConsumoConsumibleList;

    public Consumible() {
    }

    public Consumible(Integer idConsumible) {
        this.idConsumible = idConsumible;
    }

    public Consumible(Integer idConsumible, String nombre, String estatus) {
        this.idConsumible = idConsumible;
        this.nombre = nombre;
        this.estatus = estatus;
    }

    public Integer getIdConsumible() {
        return idConsumible;
    }

    public void setIdConsumible(Integer idConsumible) {
        this.idConsumible = idConsumible;
    }

    public BigDecimal getCosto() {
        return costo;
    }

    public void setCosto(BigDecimal costo) {
        this.costo = costo;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    
    public String getEstatus() {
        return estatus;
    }

    public void setEstatus(String estatus) {
        this.estatus = estatus;
    }

    @XmlTransient
    public List<Categoria> getCategoriaList() {
        return categoriaList;
    }

    public void setCategoriaList(List<Categoria> categoriaList) {
        this.categoriaList = categoriaList;
    }

    public Persona getIdPersonaProveedor() {
        return idPersonaProveedor;
    }

    public void setIdPersonaProveedor(Persona idPersonaProveedor) {
        this.idPersonaProveedor = idPersonaProveedor;
    }

    public Usuario getIdUsuario() {
        return idUsuario;
    }

    public void setIdUsuario(Usuario idUsuario) {
        this.idUsuario = idUsuario;
    }

    @XmlTransient
    public List<OperarConsumoConsumible> getOperarConsumoConsumibleList() {
        return operarConsumoConsumibleList;
    }

    public void setOperarConsumoConsumibleList(List<OperarConsumoConsumible> operarConsumoConsumibleList) {
        this.operarConsumoConsumibleList = operarConsumoConsumibleList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idConsumible != null ? idConsumible.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Consumible)) {
            return false;
        }
        Consumible other = (Consumible) object;
        if ((this.idConsumible == null && other.idConsumible != null) || (this.idConsumible != null && !this.idConsumible.equals(other.idConsumible))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "modelo.Consumible[ idConsumible=" + idConsumible + " ]";
    }
    
}
